<!DOCTYPE>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>灵活保险补贴申请</title>
  <link rel="stylesheet" href="./styles/css/common.css">
  <link rel="stylesheet" href="./styles/css/jbxx.css">
</head>

<body>
  <div class="all">
    <!-- 头部开始 -->
    <script src="http://rsj.beijing.gov.cn/images/rsj_header.js"></script>
    <include src="./include/head.html"></include>
    <!-- 申请提示开始 -->
    <div class="message">
      <div class="content">
        <div class="zuo left">
          <div class="titles concommon">
            <a href="./index.html">
              < 首页</a> <span class="on">|</span>
                <span>灵活就业</span>
          </div>
          <div class="jyxx concommon" id="detailWrap">
            <form name="form_person" msgtype="2" validate="blur">
              <div>
                <div class="clearfix">
                  <p class="col_4 left color_b"><span style="color: red;">*</span> 灵活就业工种：</p>
                  <p class="col_3 left">
                    <select id="lhjygz" paramete="lhjygz" valiflag="7,full,灵活就业工种" v_require class="J_lhjygz" value=""></select>
                  </p>
                </div>
                <div class="clearfix">
                  <p class="col_4 left color_b J_change_txt"><span style="color: red;">*</span>工作内容：
                  </p>
                  <p class="col_3 left">
                    <input type="text" id="gznr" value="" class="J_gznr" paramete="gznr" valiflag="100,full ,工作内容" v_require J_placeholder="请输入工作内容" />
                  </p>
                </div>
                <div class="clearfix J_ssjd">
                  <p class="col_4 left color_b"><span style="color: red;">*</span> 所属街道：</p>
                  <p class="col_3 left">
                    <input type="text" id="xzqhdm" paramete="xzqhdm" class="J_xzqh_select J_xzqhdm" xzqhdmid="" value="" placeholder="请输入所属街道" valiflag=",full,所属街道" v_require>
                  </p>
                </div>
                <div class="clearfix">
                  <p class="col_4 left color_b J_change_txt"><span style="color: red;">*</span>工作详细地址：
                  </p>
                  <p class="col_3 left">
                    <input type="text" id="gzxxdz" value="" class="J_xxdz" paramete="xxdz" valiflag="128,full ,工作详细地址" v_require J_placeholder="请输入工作详细地址" />
                  </p>
                </div>
                <div class="clearfix">
                  <p class="col_4 left color_b J_change_txt"><span style="color: red;">*</span>月收入：
                  </p>
                  <p class="col_3 left">
                    <select type="text" class="J_ysr" id="ysr" value="" paramete="ysr" valiflag="10,full,月收入" v_require></select>
                  </p>
                </div>
                <div class="clearfix J_xll">
                  <p class="col_4 left color_b J_change_txt"><span style="color: red;">*</span>学历：
                  </p>
                  <p class="col_3 left">
                    <select type="text" class="J_xl" id="xl" value="" paramete="xl" valiflag=",full,学历" v_require></select>
                  </p>
                </div>
                <div class="clearfix">
                  <p class="col_4 left color_b J_change_txt"><span style="color: red;">*</span>居住地邮政编码：</p>
                  <p class="col_3 left">
                    <input type="text" id="jzdyzbm" value="" class="J_jzdyzbm" paramete="jzdyzbm" valiflag="6,yb,居住地邮政编码" v_require J_placeholder="请输入居住地邮政编码" />
                  </p>
                </div>
                <div class="clearfix">
                  <p class="col_4 left color_b J_change_txt">电子邮箱：</p>
                  <p class="col_3 left">
                    <input type="text" id="dzyx" value="" class="J_dzyx" valiflag="48,email,电子邮箱" paramete="dzyx" J_placeholder="请输入电子邮箱" />
                  </p>
                </div>
                <div class="clearfix">
                  <p class="col_4 left color_b J_change_txt">联系电话：</p>
                  <p class="col_3 left">
                    <input type="text" id="lxdh" value="" class="J_lxdh" valiflag="32,lxdh,联系电话" paramete="lxdh" J_placeholder="请输入联系电话" />
                  </p>
                </div>
                <div class="clearfix">
                  <p class="col_4 left color_b J_change_txt">紧急联系人（固话、手机、微信）：</p>
                  <p class="col_3 left">
                    <input type="text" id="jjlxr" value="" class="J_jjlxr" valiflag="32,full,紧急联系人（固话、手机、微信）" paramete="jjlxr" J_placeholder="请输入紧急联系人" />
                  </p>
                </div>
                <div class="clearfix">
                  <p class="col_4 left color_b J_change_txt"><span style="color: red;">*</span>开户银行：
                  </p>
                  <p class="col_3 left">
                    <select type="text" class="J_khyh" id="khyh" value="" valiflag=" 80,full,开户银行" paramete="hdkhyh" v_require></select>
                  </p>
                </div>
                <div class="clearfix">
                  <p class="col_4 left color_b J_change_txt"><span style="color: red;">*</span>银行账号：
                  </p>
                  <p class="col_3 left">
                    <input type="text" id="yhzh" value="" class="J_yhzh J_hdyhzh" valiflag="50,full,银行账号" paramete="hdyhzh" v_require J_placeholder="请输入银行账号" />
                  </p>
                </div>
                <div class="clearfix fLhjyFlag">
                  <p class="col_4 left color_b upload_txt"><span style="color: red;">*</span>上传近期免冠照片：
                  </p>
                  <p class="col_3 left">
                    <div class="ht_img_wrap clearfix left J_upload_box">
                      <!-- 回显图片 -->
                      <div class="img_wrap J_preview">
                        <img class="img_ele J_img_zheng" src="">
                        <i class="del J_tpdel" title="删除"></i>
                      </div>
                      <!-- 添加图片 -->
                      <div class="img_wrap J_tianjia J_file_upload">
                        <label for="fileupload" class="file_upload left">点击上传</label>
                        <input type="file" accept="image/jpg,image/png,image/bmp,image/jpeg" class="inputfile tp_upload left" id="fileupload">
                      </div>
                    </div>
                  </p>
                </div>
                <p class="tsxx fLhjyFlag">（请上传小于2M的.jpg、.png、.bmp、.jpeg格式的图片）</p>
            </form>
            <div class="alertBtn alertCommon">
              <div class="btn btn_blue_deep J_goback">返回</div>
              <div class="btn btn_blue_deep J_qx">下一步</div>
            </div>
          </div>
        </div>
      </div>
      <include src="./include/right.html"></include>
    </div>
    <!-- 尾部开始 -->
    <script src="http://rsj.beijing.gov.cn/footer.js"></script>
    <!-- 尾部结束 -->
  </div>


  <script src="./common/vendor.js"></script>
  <script src="./common/validator.js"></script>
  <script src="./common/levelPlugin.js"></script>
  <script src="./common/generaltools.js"></script>
  <script src="./common/common.js"></script>
  <script>
    $(function() {
      var loading = new $.Loading();

      var sfgxbys = sessionStorage.getItem('sfgxbys'); //是否高校毕业生
      // var sqid = sessionStorage.getItem('sqid'); //是否高校毕业生
      var sqid = $.paramObj().sqid; //申请id
      var khh, lhgz, mysr; //开户行，灵活就业工种，月收入
      var cdg_educationallevel = "cdg_educationallevel"
      getKhyh(); //开户银行
      getLhjygz(); //灵活就业工种
      getYsr(); //月收入
      getDmbCx(); //学历
      if (sfgxbys == '1') {
        $('.J_ssjd').show();
        $(".J_xll").show()
      } else {
        $('.J_ssjd').hide();
        $(".J_xll").hide()
        $('.J_xzqh_select').removeAttr('v_require').val('');
      }
      if (sqid) {
        getSqxx(); //详情信息 图片
      }else{
        $.showPlaceholder();
      }

      //灵活就业工种
      function getLhjygz() {
        loading.on();
        $.fetch({
          url: '/lhsq/lhgzCx',
          type: 'get',
        }).done(function(res) {
          var _res = res.returnData;
          if (+_res.executeResult === 1) {
            loading.off();
            var _str = '';
            if (_res.lhgz.length == 0) {
              _str += '<option value=""></option>'
              $('#lhjygz').html(_str)
            } else {
              _str += '<option value="">请选择</option>'
              for (var i = 0; i < _res.lhgz.length; i++) {
                _str += '<option value="' + _res.lhgz[i].dmid + '">' + _res.lhgz[i].dmmc + '</option>'
              }
              $('#lhjygz').html(_str)
              loading.off();
			}
			
			if (sessionStorage.getItem('sfgxbys') == "1") {
				$('.J_lhjygz').val('0000014')
				$(".J_lhjygz").attr("disabled", true);
			}else{
        $('.J_lhjygz option[value="0000014"]').attr("disabled",true)
      }
          } else {
            $.layerMsg(_res.message, '确定');
            loading.off();
          }
        })
      };
      //月收入
      function getYsr() {
        $.fetch({
          url: '/lhsq/ysrCx',
          type: 'get',
        }).done(function(res) {
          var _res1 = res.returnData;
          if (+_res1.executeResult === 1) {
            var _str1 = '';
            if (_res1.khyh.length == 0) {
              _str1 += '<option value=""></option>'
              $('#ysr').html(_str1)
            } else {
              _str1 += '<option value="">请选择</option>'
              for (var i = 0; i < _res1.khyh.length; i++) {
                _str1 += '<option value="' + _res1.khyh[i].dmid + '">' + _res1.khyh[i].dmmc + '</option>'
              }
              $('#ysr').html(_str1)
            }
          }
        })
      };

      //开户银行
      function getKhyh() {
        $.fetch({
          url: '/lhsq/khyhCx',
          type: 'get',
        }).done(function(res) {
          var _res2 = res.returnData;
          if (+_res2.executeResult === 1) {
            var _str2 = '';
            if (_res2.khyh.length == 0) {
              _str2 += '<option value=""></option>'
              $('#khyh').html(_str2)
            } else {
              _str2 += '<option value="">请选择</option>'
              for (var i = 0; i < _res2.khyh.length; i++) {
                _str2 += '<option value="' + _res2.khyh[i].dmid + '">' + _res2.khyh[i].dmmc + '</option>'
              }
              $('#khyh').html(_str2)
            }
          }
        })
      };
      //学历
      function getDmbCx() {
        $.fetch({
          url: '/lhsq/getDmbCx',
          type: 'get',
          data: {
            tablename: cdg_educationallevel
          }
        }).done(function(res) {
          var _res3 = res.returnData;
          if (+_res3.executeResult === 1) {
            var _str3 = '';
            if (_res3.dmb.length == 0) {
              _str3 += '<option value=""></option>'
              $('#khyh').html(_str3)
            } else {
              _str3 += '<option value="">请选择</option>'
              for (var i = 0; i < _res3.dmb.length; i++) {
                _str3 += '<option value="' + _res3.dmb[i].dmid + '">' + _res3.dmb[i].dmmc + '</option>'
              }
              $('#xl').html(_str3)
            }
          }
        })
      };
      //所属街道
      getMayDmb()
      function getMayDmb() {
        $.ajax({
          url: './common/bjs3j.json'
        }).done(function(res) {
          $('.J_xzqh_select').pull(res);
        });
      }
      window.getXzqh = getXzqh;

      function getXzqh(data, ele) {
        $('.J_xzqh_select').attr('xzqhdmid', data.id);
      }
      $(".J_preview").hide()
      // 上传图片
      $('body').on('change', '.tp_upload', function() {
        
        var $this = $(this);
        if($('.img_ele').attr("src","")){
          var $this = $(this);
        $this.upload({
          success: function(res) {
            var data = res.returnData;
            var flag = parseInt(data.executeResult, 10);
            if (flag === 1) {
              $('.J_img_zheng').attr({
                'src': tphx(data.tpid),
                'id': data.tpid
              });
              $('.J_img_zheng').parents('.J_preview').show(); //图片回显
              $('.tp_upload').parents('.J_file_upload').hide(); //添加
            } else {
              $.layerMsg(data.message, '确定');
              return false;
            }
          },
          error: function(res) {}
        });
        }
       
      });
      // 删除图片
      $('body').on('click', '.J_tpdel', function() {
        //每次删除的时候 把input 属性变更
        $("#fileupload").attr('type','text');
        $("#fileupload").attr('type','file');
        $('.J_img_zheng').attr("src","");
        $('.J_img_zheng').attr("id","");
        $('.J_preview').hide();
        $('.J_tianjia').show();
      });

      function getSqxx() {
        loading.on();
        $.fetch({
          url: '/lhsq/sqxx',
          type: 'get',
          data: {
            sqid: sqid
          }
        }).done(function(result) {
          loading.off();
          var res = result.returnData;
          var formData = $('form[name="form_person"]').getFormData();
          if (res.executeResult == 1) {
            
            var sqxxList = res.sqxx;
            for (var i in formData) { //毕业院校以下
              $('.J_' + i).val(sqxxList[i])
            }
            $('.J_xzqhdm').val(sqxxList.xzqhdmmc); //所属街道
            $('.J_khyh').val(sqxxList.hdkhyh); //开户银行
            $('.J_xzqh_select').attr('xzqhdmid', sqxxList.xzqhdm);
            if (sqxxList.mgzptpid) {
              $('.J_img_zheng').attr({
                'src': tphx(sqxxList.mgzptpid),
                'id': sqxxList.mgzptpid
              });
              $('.J_img_zheng').parents('.J_preview').show(); //图片回显
              $('.tp_upload').parents('.J_file_upload').hide(); //添加
            }
          } else {
            $.layerMsg(res.message, '确定');
            return false;
          }
        })
      }
      //图片回显
      function tphx(id) {
        return conf.urlPrefix + "/wjsc/tpxs?tpid=" + id;
      }

      //确定
      $(document).on('click', '.J_qx', function() {
        if (sessionStorage.getItem('sfgxbys') == "") {
          $(".J_xzqhdm").removeAttr("v_require");
          $(".J_xl").removeAttr("v_require");
        }
        if (!validate('form_person')) return false;
        var getFormData = $('form[name="form_person"]').getFormData();
        getFormData.mgzptpid = $('.J_img_zheng').attr('id');
        getFormData.xzqhdm = $('.J_xzqh_select').attr('xzqhdmid');
        getFormData.sqid = sqid;
        getFormData.sfgxbys = sessionStorage.getItem('sfgxbys');
        if(getFormData.ysr.constructor== Array){
          getFormData.ysr=getFormData.ysr[0];
        }
        if(getFormData.xl.constructor== Array){
          getFormData.xl=getFormData.xl[0];
        }
        if(getFormData.hdkhyh.constructor== Array){
          getFormData.hdkhyh=getFormData.hdkhyh[0];
        }
        //开户银行为邮政储蓄时，银行账号必须为14,18或19位
        var khh = $('.J_khyh').val(); //开户银行名称
        var yhzhLen = $('.J_yhzh').val().length; //银行账号位数
        if (khh == '03' && yhzhLen != 14 && yhzhLen != 18 && yhzhLen != 19) {
          $.layerMsg('开户银行为邮政储蓄时，银行账号必须为14,18或19位！', '确定');
          return false;
        }
        if (khh == '80' && yhzhLen != 16) {
          $.layerMsg('开户银行为北京银行时，银行账号必须为16位！', '确定');
          return false;
        }
        // 正整数
        var yhzhVal = $('.J_yhzh').val();  // 银行卡号
        var reg = /^[\d]+$/;
        if(!reg.test(yhzhVal)){
          $.layerMsg('银行账号必须是全数字！', '确定');
          return false;
        }
        //近期照片不能为空
        if (!getFormData.mgzptpid) {
          $.layerMsg('请上传近期免冠照片！', '确定');
          return false;
        }
              loading.on();
              $.fetch({
                url: '/lhsq/sqBc',
                type: 'post',
                data: getFormData
              }).always(function(){
                loading.off();
              }).done(function(res) {
                var _res = res.returnData;
                if (_res.executeResult == 1) {
                  sqid = _res.sqid;
                  $.layerMsg('保存成功！', '确定', function() {
                    window.location.href = './xsbtcns.html?sqid=' + sqid;
                  });
                } else {
                  $.layerMsg(_res.message, '确定');
                  loading.off();
                }
              })
           
      });
      //返回
      $(document).on('click', '.J_goback', function() {
        window.location.href = './index.html'
      });
    });
  </script>
</body>

</html>